/**
 * 
 */
package com.sci.web.daoimpl;

import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.SqlMapClientCallback;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ibatis.sqlmap.client.SqlMapExecutor;
import com.sci.web.bean.Enterprise_Brand;
import com.sci.web.bean.Enterprise_Funds;
import com.sci.web.bean.Enterprise_Innovation;
import com.sci.web.bean.Enterprise_Labor_Capacity;
import com.sci.web.bean.Enterprise_Management;
import com.sci.web.bean.Enterprise_New;
import com.sci.web.bean.Enterprise_Patent;
import com.sci.web.bean.Enterprise_Strategy;

/**
 * @author BaiFuyou
 * @date: Nov 7, 2011 5:09:35 PM
 */
public class DataReportM_InnovateBaseDao extends SqlMapClientDaoSupport implements com.sci.web.dao.DataReportM_InnovateBaseDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sci.web.dao.DataReportM_InnovateBaseDao#insertBatchEnterprise_Funds(java.util.List)
	 */
	@Override
	public boolean insertBatchEnterprise_Funds(final List<Enterprise_Funds> ef) {
		// TODO Auto-generated method stub
		boolean flag = false;
		try {
			if (ef != null) {
				this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {

					@Override
					public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
						// TODO Auto-generated method stub
						executor.startBatch();
						for (int i = 0; i < ef.size(); i++) {
							executor.insert("datereportseason.insertnewEnterprise_Funds", ef.get(i));
						}
						executor.executeBatch();
						return null;
					}
				});
				flag = true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
		}
		return flag;
	}
	@Override
	public int getEnterpriseBaseId(int uid) {
		// TODO Auto-generated method stub
		return (Integer) super.getSqlMapClientTemplate().queryForObject("datereportseason.getenid", uid);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Enterprise_Funds> getAllEnterprise_FundsforPageLoad(Map<String, Object> map) {
		// TODO Auto-generated method stub
		List<Enterprise_Funds> list = super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_Funds", map);
		Collections.sort(list);
		return list;
	}

	@Override
	public boolean updateEnterprise_Funds(Enterprise_Funds ef) {
		// TODO Auto-generated method stub
		return (Integer) super.getSqlMapClientTemplate().update("datereportseason.updateEnterprise_Funds", ef) > 0 ? true : false;
	}

	@Override
	public boolean addNewEnterprise_Funds(Enterprise_Funds ef) {
		// TODO Auto-generated method stub
		return (Integer) super.getSqlMapClientTemplate().insert("datereportseason.insertnewEnterprise_Funds", ef) > 0 ? true : false;
	}

	@Override
	public boolean isNewEnterprise_FundsExist(Map<String, Object> ef) {
		// TODO Auto-generated method stub
		return (Integer) super.getSqlMapClientTemplate().queryForObject("datereportseason.isEnterprise_FundsExist", ef) > 0 ? true : false;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Enterprise_Funds> getAllEnterprise_FundsByUid(int uid) {
		// TODO Auto-generated method stub
		return super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_Fundsbyuid", uid);
	}

	@Override
	public boolean deleteOneEnterprise_FundsByFidEid(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer) super.getSqlMapClientTemplate().delete("datereportseason.deleteEnterprise_Fundsbyuidandeid", map) > 0 ? true : false;
	}

	@Override
	public boolean deleteOneEnterprise_PatentData(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().delete("datereportseason.deleteoneEnterprise_Patent",map)>0?true:false;
	}

	@Override
	public List<Enterprise_Patent> getAllEnterprise_PatentByUid(int uid) {
		// TODO Auto-generated method stub
		return super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_PatentByUId",uid);
	}

	@Override
	public boolean insertNewEnterprise_PatentData(Enterprise_Patent ep) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().insert("datereportseason.insertnewEnterprise_Patent",ep)>0?true:false;
	}

	@Override
	public boolean isNewEnterprise_PatentExist(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().queryForObject("datereportseason.getisexistEnterprise_Patent",map)>0?true:false;
	}

	@Override
	public boolean deleteEnterprise_NewData(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().delete("datereportseason.deleteoneEnterprise_New",map)>0?true:false;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Enterprise_New> getAllEnterprise_NewByUid(int uid) {
		// TODO Auto-generated method stub
		return super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_Newbyuid",uid);
	}

	@Override
	public boolean insertEnterprise_NewData(Enterprise_New en) {
		// TODO Auto-generated method stub isEnterprise_Newalreadyexist
		return (Integer)super.getSqlMapClientTemplate().insert("datereportseason.insertEnterprise_NewData",en)>0?true:false;
	}

	@Override
	public boolean isEnterprise_NewExistBeforeInsert(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().queryForObject("datereportseason.isEnterprise_Newalreadyexist",map)>0?true:false;
	}

	@Override
	public boolean deleteOneEnterprise_Labor_Capacity(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().delete("datereportseason.deleteoneenterprise_labor_capacity",map)>0?true:false;
	}

	@Override
	public List<Enterprise_Labor_Capacity> getAllEnterprise_Labor_CapacityByUid(int uid) {
		// TODO Auto-generated method stub
		return super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_Labor_Capacity",uid);
	}

	@Override
	public boolean insertNewEnterprise_Labor_Capacity(Enterprise_Labor_Capacity elc) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().insert("datereportseason.insertnewenterprise_labor_capacity",elc)>0?true:false;
	}

	@Override
	public boolean isEnterprise_Labor_CapacityExistBeforeInsert(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().queryForObject("datereportseason.islabor_capacity_check_passexistbeforeinsert",map)>0?true:false;
	}
	@Override
	public boolean deleteOneEnterprise_BrandData(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().delete("datereportseason.deleteoneenterprise_brand",map)>0?true:false;
	}
	@Override
	public boolean deleteOneEnterprise_ManagementData(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().delete("datereportseason.deleteoneEnterprise_Management",map)>0?true:false;
	}
	@Override
	public boolean deleteOneEnterprise_StrategyByid(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().delete("datereportseason.deleteEnterprise_Strategy",map)>0?true:false;
	}
	@Override
	public List<Enterprise_Brand> getAllEnterprise_BrandDataByuid(int uid) {
		// TODO Auto-generated method stub
		return super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_Brandbyuid",uid);
	}
	@Override
	public List<Enterprise_Management> getAllEnterprise_ManagementByUid(int uid) {
		// TODO Auto-generated method stub
		return super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_Management",uid);
	}
	@Override
	public List<Enterprise_Strategy> getAllEnterprise_StrategyByUid(int uid) {
		// TODO Auto-generated method stub
		return super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_Strategy",uid);
	}
	@Override
	public boolean insertNewEnterprise_BrandData(Enterprise_Brand eb) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().insert("datereportseason.insertnewenterprise_brand",eb)>0?true:false;
	}
	@Override
	public boolean insertNewEnterprise_ManagementData(Enterprise_Management em) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().insert("datereportseason.insertnewEnterprise_Management",em)>0?true:false;
	}
	@Override
	public boolean insertNewEnterprise_StrategyData(Enterprise_Strategy es) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().insert("datereportseason.insertnewEnterprise_Strategy",es)>0?true:false;
	}
	@Override
	public boolean isEnterprise_StrategyExistBeforeInsert(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().queryForObject("datereportseason.isExistBeforeInsertEnterprise_Strategy",map)>0?true:false;
	}
	@Override
	public boolean isExistBeforeInsertEnterprise_Brand(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().queryForObject("datereportseason.isExistBeforeInsertenterprise_brand",map)>0?true:false;

	}
	@Override
	public boolean isExistBeforeInsertEnterprise_Management(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().queryForObject("datereportseason.isexistbeforeEnterprise_Managementinsert",map)>0?true:false;
	}
	@Override
	public boolean deleteOneEnterprise_InnovationByMap(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().delete("datereportseason.deleteoneEnterprise_Innovation",map)>0?true:false;
	}
	@Override
	public List<Enterprise_Innovation> getAllEnterprise_InnovationByUid(int uid) {
		// TODO Auto-generated method stub
		return super.getSqlMapClientTemplate().queryForList("datereportseason.getallEnterprise_Innovationbyuid",uid);
	}
	@Override
	public boolean insertNewEnterprise_InnovationData(Enterprise_Innovation ei) {
		// TODO Auto-generated method stub
		return (Integer)super.getSqlMapClientTemplate().insert("datereportseason.insertnewEnterprise_Innovation",ei)>0?true:false;
	}
	@Override
	public boolean isExistBeforeEnterprise_InnovationInsert(Map<String, Object> map) {
		// TODO Auto-generated method stub  
		return (Integer)super.getSqlMapClientTemplate().queryForObject("datereportseason.isEnterprise_InnovationExistbeforeInsert",map)>0?true:false;
	}

}
